import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'

const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    name: '',
    component: () => import('../views/MainApp.vue'),
  },

  {
    path: '/Login',
    name: 'Login',
    component: () => import('../views/LoginView.vue'),
  },

  {
    path: '/goodsDetails/:id',
    name: 'goodsDetails',
    component: () => import('../views/GoodsDetail.vue'),
  },

  {
    path: '/customerPlace',
    name: 'customerPlace',
    component: () => import('../views/CustomerPlace.vue'),
    redirect: '/customer/info',  //默认进入时的界面
    //子路由，用于显示个人中心右边的内容
    children: [
      {path: '/customer/order', name: 'customerOrder',component: () => import('../views/customer/orderOfGoods.vue'),},
      {path: '/customer/shoppingCar', name: 'customerShoppingCar',component: () => import('../views/customer/shoppingCar.vue'),},
      {path: '/customer/info', name: 'customerInfo',component: () => import('../views/customer/basicInfo.vue'),},
      {path: '/customer/changeAvatar', name: 'customerChangeAvatar',component: () => import('../views/customer/changeAvatar.vue'),},
      {path: '/customer/changePassword', name: 'customerChangePassword',component: () => import('../views/customer/changePassword.vue'),},
    ],
  },
  
  {
    path: '/businessPlace',
    name: 'businessPlace',
    component: () => import('../views/BusinessPlace.vue'),
    redirect: '/business/goodsManager',  //默认进入时的界面
    //子路由，用于显示个人中心右边的内容
    children: [
      {path: '/business/browsingHistory', name: 'businessBrowsingHistory', component: () => import('../views/business/browsingHistory.vue')},
      {path: '/business/goodsManager', name: 'businessGoodsManager',component: () => import('../views/business/goodsManager.vue'),},
      {path: '/business/order', name: 'businessOrder',component: () => import('../views/business/orderOfGoods.vue'),},
      {path: '/business/info', name: 'businessInfo',component: () => import('../views/business/basicInfo.vue'),},
      {path: '/business/changeAvatar', name: 'businessChangeAvatar',component: () => import('../views/business/changeAvatar.vue'),},
      {path: '/business/changePassword', name: 'businessChangePassword',component: () => import('../views/business/changePassword.vue'),},
      {path: '/business/salesReport', name: 'salesReport', component: () => import('../views/business/salesReport.vue'),},
    ],
  },

  {
    path: '/PurchaseGoods',
    name: 'purchaseGoods',
    component: () => import('../views/PurchaseGoods.vue'),
  },
]

const router = createRouter({
  history: createWebHashHistory(),
  routes
})

export default router
